// API 接口统一出口
import request from './request'

// 用户相关接口
export const userApi = {
  // 用户登录
  login: (data) => request.post('/login', data),
  
  // 用户登出
  logout: () => request.post('/auth/logout'),
  
  // 获取用户信息
  getUserInfo: () => request.get('/user/info'),
  
  // 获取用户列表
  getUserList: (params) => request.get('/user/list', { params }),
  
  // 创建用户
  createUser: (data) => request.post('/user/create', data),
  
  // 更新用户
  updateUser: (id, data) => request.put(`/user/update/${id}`, data),
  
  // 删除用户
  deleteUser: (id) => request.delete(`/user/delete/${id}`)
}

// 角色相关接口
export const roleApi = {
  // 获取角色列表
  getRoleList: (params) => request.get('/role/list', { params }),
  
  // 创建角色
  createRole: (data) => request.post('/role/create', data),
  
  // 更新角色
  updateRole: (id, data) => request.put(`/role/update/${id}`, data),
  
  // 删除角色
  deleteRole: (id) => request.delete(`/role/delete/${id}`)
}

// 权限相关接口
export const permissionApi = {
  // 获取权限列表
  getPermissionList: (params) => request.get('/permission/list', { params }),
  
  // 创建权限
  createPermission: (data) => request.post('/permission/create', data),
  
  // 更新权限
  updatePermission: (id, data) => request.put(`/permission/update/${id}`, data),
  
  // 删除权限
  deletePermission: (id) => request.delete(`/permission/delete/${id}`)
}

// 文章相关接口
export const articleApi = {
  // 获取文章列表
  getArticleList: (params) => request.get('/article/list', { params }),
  
  // 创建文章
  createArticle: (data) => request.post('/article/create', data),
  
  // 更新文章
  updateArticle: (id, data) => request.put(`/article/update/${id}`, data),
  
  // 删除文章
  deleteArticle: (id) => request.delete(`/article/delete/${id}`)
}

// 分类相关接口
export const categoryApi = {
  // 获取分类列表
  getCategoryList: (params) => request.get('/category/list', { params }),
  
  // 创建分类
  createCategory: (data) => request.post('/category/create', data),
  
  // 更新分类
  updateCategory: (id, data) => request.put(`/category/update/${id}`, data),
  
  // 删除分类
  deleteCategory: (id) => request.delete(`/category/delete/${id}`)
}

// 仪表盘相关接口
export const dashboardApi = {
  // 获取统计数据
  getStats: () => request.get('/dashboard/stats')
}

// 默认导出所有API
export default {
  userApi,
  roleApi,
  permissionApi,
  articleApi,
  categoryApi,
  dashboardApi
}